package com.itheima.controller;

import com.itheima.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {
    @RequestMapping("/save")
    @ResponseBody
    public String save(){
        System.out.println("controller");
        return "{'zhangsan','lisi'}";
    }

    @RequestMapping("/delete")
    @ResponseBody
    public String delete(){
        System.out.println("controller...");
        return "{'delete','lisi'}";
    }

    @RequestMapping("/listparam")
    @ResponseBody
    public String listparam(@RequestBody List<String> likes){
        System.out.println("list json controller... list==>" +likes);
        return "{'model':'lisi common for json param'}";
    }

    @RequestMapping("/pojoparam")
    @ResponseBody
    public String pojoparam(@RequestBody User user){
        System.out.println("user json controller... pojo==>" +user);
        return "{'model':'pojo for json param'}";
    }

    @RequestMapping("/listpojoparam")
    @ResponseBody
    public String listpojoparam(@RequestBody List<User> list){
        System.out.println("user json controller... listpojo==>" +list);
        return "{'model':'list pojo for json param'}";
    }
}
